package com.wanxi.model;

import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.wanxi.util.IdJsonSerialize;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;

import java.util.Collection;
import java.util.HashSet;
import java.util.Set;


/**
 * @author 杨金乾
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
public class UserModel implements UserDetails {
    @JsonSerialize(using = IdJsonSerialize.class)
    private Long id;
    private String createTime;
    private String updateTime;
    private String updateTimeStart;
    private String updateTimeEnd;
    private Integer enable;
    private String remark;

    private Integer page;
    private Integer limit;

    private String username;
    private String password;
    private String newPassword;
    private String sex;
    private String email;
    private String phone;
    private String birthday;
    private String birthdayStart;
    private String birthdayEnd;

    private Integer age;
    private String address;
    private String hobby;
    private Set<? extends GrantedAuthority> authorities;

    @Override
    public Collection<? extends GrantedAuthority> getAuthorities() {
        return this.authorities;
    }

    @Override
    public boolean isAccountNonExpired() {
        return true;
    }

    @Override
    public boolean isAccountNonLocked() {
        return true;
    }

    @Override
    public boolean isCredentialsNonExpired() {
        return true;
    }

    @Override
    public boolean isEnabled() {
        return true;
    }
}
